package com.lujianfei.switchtheme

import android.os.Bundle
import android.util.TypedValue
import com.lujianfei.switchtheme.base.BaseActivity
import com.lujianfei.switchtheme.utils.FileHelper
import com.lujianfei.switchtheme.utils.SkinManager
import kotlinx.android.synthetic.main.activity_main.*
import java.io.File

class NewActivity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_new)
        switch_theme.setOnClickListener {
            SkinManager.INSTANCE.loadSkin(FileHelper.getSDcardDir() + File.separator + "myskin" + File.separator + "my.skin")
        }
        restore_theme.setOnClickListener {
            SkinManager.INSTANCE.restoreDefaultTheme()
        }
        SkinManager.INSTANCE.getColor(R.color.default_text_color)?.let {
            switch_theme.setTextColor(it)
            restore_theme.setTextColor(it)
        }
        SkinManager.INSTANCE.getDimension(R.dimen.default_textsize)?.let {
            switch_theme.setTextSize(TypedValue.COMPLEX_UNIT_PX,it)
            restore_theme.setTextSize(TypedValue.COMPLEX_UNIT_PX,it)
        }
    }
}
